<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="${staticServer}/inc/style/main.css"/>
    <link rel="stylesheet" href="${staticServer}/inc/style/page.css"/>
    <link rel="stylesheet" href="${staticServer}/css/struct_info.css"/>
    <script src="${staticServer}/inc/js/jquery.js"></script>
    <script src="${staticServer}/inc/js/pageset.js"></script>
    <script src="${staticServer}/inc/js/submitter.js"></script>
    <script src="${staticServer}/inc/js/infopad.js?2.2"></script>
    <script type="text/javascript" src="${staticServer}/common/uploadify/jquery.uploadify.js"></script>
    <script type="text/javascript" src="${staticServer}/js/web/uploadImg.js?1.5"></script>

    <link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css"/>
    <script src="${staticServer}/inc/js/datepicker.js"></script>

    <script>
        var contextPath = '${contextPath}';
        var _contextPath = '${staticServer}';

        $(function () {
            $("#type").val("<#if goods??>${goods.type}</#if>");
            $("#item").val("<#if goods??>${goods.id}</#if>");
            
            var good_mnus="<#if goods??>${goods.good_pard_id}</#if>";
                            if(good_mnus==1){
								$("#dnxh").show();
								$("#bh").show();
								$("#fey").hide();
								$("#kdxh").hide();
								$("#contz").show();
								$("#nummone").show();
								$("#numb").show();
                            }else if(good_mnus==2){
								$("#kdxh").show();
								$("#fey").show();
								$("#dnxh").hide();
								$("#bh").hide();
								$("#contz").hide();
								$("#nummone").hide();
								$("#numb").hide();
							}else if(good_mnus==3){
								$("#cglink").show();
								$("#dnxh").hide();
								$("#bh").hide();
								$("#fey").hide();
								$("#kdxh").hide();
								$("#contz").show();
								$("#nummone").show();
								$("#numb").show();
							}else{
								$("#dnxh").hide();
								$("#bh").hide();
								$("#fey").hide();
								$("#kdxh").hide();
								$("#cglink").hide();
								$("#contz").show();
								$("#nummone").show();
								$("#numb").show();
							}


        });

    </script>
    <script>
        function selectGoods() {
            var id = $("#item option:selected").val();
            $.ajax({
                type: 'POST',
                url: 'ajaxSelectGoods.htm',
                data: {"id": id},
                dataType: "json",
                success: function (data) {
                    if (data != null) {
                        for (var p in data) {//遍历json对象的每个key/value对,p为key
                            $("#type").val(data['type'])
                            $("#center_name").val(data['center_name'])
                            $("#good_parint_name").val(data['good_parint_name']+' : '+data['goods_name'])
                            $("#itemName").val(data['item_name'])
                            $("#number").val(data['number'])
                            $("#unitPrice").val(data['unit_price'])
                            $("#totalCalculation").val(data['total_calculation'])
                            $("#company").val(data['company'])
                            $("#msg").val(data['msg'])
                            $("#goods_id").val(data['id'])
                            
                            $("#model").val(data['model'])
                            $("#code").val(data['code'])
                            $("#broadband_type").val(data['broadband_type'])
                            $("#supplier").val(data['supplier'])
                            $("#purchasing_link").val(data['purchasing_link'])
                            
                            var good_mnus=data['good_pard_id'];
                            if(good_mnus==1){
								$("#dnxh").show();
								$("#bh").show();
								$("#fey").hide();
								$("#kdxh").hide();
								$("#contz").show();
								$("#nummone").show();
								$("#numb").show();
                            }else if(good_mnus==2){
								$("#kdxh").show();
								$("#fey").show();
								$("#dnxh").hide();
								$("#bh").hide();
								$("#contz").hide();
								$("#nummone").hide();
								$("#numb").hide();
							}else if(good_mnus==3){
								$("#cglink").show();
								$("#dnxh").hide();
								$("#bh").hide();
								$("#fey").hide();
								$("#kdxh").hide();
								$("#contz").show();
								$("#nummone").show();
								$("#numb").show();
							}else{
								$("#dnxh").hide();
								$("#bh").hide();
								$("#fey").hide();
								$("#kdxh").hide();
								$("#cglink").hide();
								$("#contz").show();
								$("#nummone").show();
								$("#numb").show();
							}
	
                        }
                    } else {
                        alert("操作失败!");
                    }

                },
                error: function () {
                    alert("系统出现问题");
                }
            });
        }
    </script>
    <script>
        function save(flag) {
            var goodId = $("#item").val();
            var purpose = $("#purpose").val();
            
            $.post("${contextPath}/goods/saveStorage.json", {
                "flag": flag, 
                "goodId": goodId,
                 "purpose":purpose
            }, function (ms) {
                var msg = ms.msg;
                if (msg != null && msg == "1") {
                    infopad.msg("操作成功！");
                    window.location.href = "${contextPath}/goods/Goods.htm";
                } else {
                    infopad.err("操作失败，请联系管理员！");
                }

            });

        }


    </script>
</head>
<body>
<div id="home_link">
    <ul>
        <li></li>
        <li>&gt;</li>
        <li>采购管理</li>
        <li>&gt;</li>
        <li class="current">title</li>
    </ul>
</div>

<div id="container">
    <div id="title">物品出入库</div>
    <table id="infotable">
        <tr>
            <th style="color:crimson">入库物品:</th>
            <td>
                <select id="item" onchange="selectGoods()">
                <#if list??>
                    <#list list as goods>
                        <option value="${goods.id}" selected="selected">${goods.item_name}</option>
                    </#list>
                </#if>
                </select>
            </td>
        </tr>
        <tr>
            <th>类型:</th>
            <td><input id="type" disabled='disabled' 
            value=" <#if goods.type=="1">固定资产<#else >消耗品</#if>  " type="text" size="50" maxlength="30"/></td>


        </tr>

        <tr>
            <th>办公地址:</th>
            <td><input id="center_name" disabled='disabled' value="${goods.center_name}" type="text" size="50"
                       maxlength="30"/></td>
        </tr>

        <tr>
            <th>物品分类:</th>
            <td>
            <input id="good_parint_name" disabled='disabled' value="${goods.good_parint_name} : ${goods.goods_name}" type="text" size="50" maxlength="30"/></td>
                
            </td>
        </tr>
        <tr>
            <th>物品名称:</th>
            <td><input id="itemName" disabled='disabled' value="${goods.item_name}" type="text" size="50"
                       maxlength="30"/></td>
        </tr>
        <tr id="dnxh" style="display:none">
            <th >型号:</th>
            <td><input id="model" value="${goods.model}" type="text" size="50" maxlength="30"/></td>
        </tr>
        <tr  id="bh" style="display:none">
            <th>编号/编码:</th>
            <td><input id="code" value="${goods.code}" type="text" size="50" maxlength="30"/></td>
        </tr>
        <tr id="kdxh" style="display:none">
            <th >类型:</th>
            <td><input id="broadband_type" value="${goods.broadband_type}" type="text" size="50" maxlength="30" placeholder="例：联通-20M-光纤/联通卡、移动卡"/></td>
        </tr>
        <tr  id="fey" style="display:none">
            <th>费用:</th>
            <td><input id="supplier" value="${goods.supplier}" type="text" size="50" maxlength="30"/></td>
        </tr>
        <tr id="numb">
            <th>物品数量:</th>
            <td><input id="number" disabled='disabled' value="${goods.number}" onchange="totalCalculation()"
                       onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                       onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')" type="text" size="50" maxlength="30"/>
            </td>
        </tr>

        <tr id="nummone">
            <th>物品单价:</th>
            <td><input id="unitPrice" disabled='disabled' type="text" value="${goods.unit_price}"
                       onchange="totalCalculation()" onkeyup="clearNoNum(this)" size="50" maxlength="30"/></td>
        </tr>
        <tr id="contz">
            <th>总额:</th>
            <td><input id="totalCalculation" value="${goods.total_calculation}" disabled='disabled' type="text"
                       size="50" maxlength="30"/></td>
        </tr>
        <tr>
            <th>物品单位:</th>
            <td><input id="company" disabled='disabled' value="${goods.company}" type="text" size="50" maxlength="30"/>
            </td>
        </tr>
		<tr id="cglink" style="display:none">
            <th >采购链接:</th>
            <td><input id="purchasing_link" value="${goods.purchasing_link}" type="text" size="50" maxlength="30"/></td>
        </tr>
        <tr>
            <th>备注:</th>
            <td>
                <textarea id="msg" disabled='disabled' style="width:400px;height: 150px;">${goods.msg}</textarea>

            </td>
        </tr>
		<tr>
            <th>用途:</th>
            <td>
                <textarea id="purpose" style="width:400px;height: 150px;">${goods.purpose}</textarea>

            </td>
        </tr>
    </table>
    <div id="controlbar">
    <#if  flag =="1">   
        <input type="button" class="submit" onclick="save(1)" value="  入  库  "/>
    <#elseif flag=="2">
        <input type="button" class="submit" onclick="save(2)" value="  出  库  "/>
    </#if>

    </div>
</div>

</body>
</html>